package com.yzq.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yzq.model.dto.picture.*;
import com.yzq.model.entity.Picture;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yzq.model.vo.PictureVO;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
* @author yezhi
* @description 针对表【picture(图片)】的数据库操作Service
* @createDate 2025-07-02 07:13:48
*/
public interface PictureService extends IService<Picture> {

    /**
     * 上传图片到阿里云
     * @param file 文件
     * @return 图片地址
     */
    String uploadPictureToAliyun(MultipartFile file) throws Exception;

    /**
     * 上传图片
     * @param file 文件
     * @param pictureUploadRequest 图片上传请求
     * @param request 请求
     * @return 图片实体
     * @throws Exception 上传过程中出现异常
     */
    PictureVO uploadPicture(MultipartFile file, PictureUploadRequest pictureUploadRequest, HttpServletRequest  request) throws Exception;


    /**
     * 通过URL上传图片
     * @param pictureUrlUploadRequest 图片URL上传请求
     * @param request 请求
     * @return 图片实体
     * @throws Exception 上传过程中出现异常
     */
    PictureVO uploadPictureByUrl(PictureUrlUploadRequest pictureUrlUploadRequest, HttpServletRequest request) throws Exception;

    /**
     * 删除图片
     * @param pictureDeleteRequest 图片删除请求
     * @param request 删除图片的请求
     * @return 删除结果
     */
    Boolean deletePicture(PictureDeleteRequest pictureDeleteRequest, HttpServletRequest request);

    /**
     * 修改图片
     * @param pictureUpdateRequest 图片修改请求
     * @param request 请求
     * @return 修改结果
     */
    Boolean updatePicture(PictureUpdateRequest pictureUpdateRequest, HttpServletRequest request);

    /**
     * 获取图片分页列表
     * @param pictureQueryRequest 图片查询请求
     * @return 图片分页列表
     */
    Page<PictureVO> getPictureList(PictureQueryRequest pictureQueryRequest);

    /**
     * 根据 id 获取图片信息
     * @param id 图片 id
     * @return 图片信息
     */
    PictureVO getPictureById(Long id, HttpServletRequest request);

    /**
     * 管理员获取图片列表
     * @param pictureQueryRequest 图片查询请求
     */
    Page<Picture> getPictureListByAdmin(PictureQueryRequest pictureQueryRequest);

    /**
     * 审核图片
     * @param pictureReviewRequest 图片审核请求
     * @param request 请求
     * @return 审核结果
     */
    Boolean reviewPicture(PictureReviewRequest pictureReviewRequest, HttpServletRequest request);

    /**
     * 批量抓取和创建图片
     * @param pictureUploadByBatchRequest 图片批量上传请求
     * @param request 请求
     * @return 批量创建结果数
     */
    Integer uploadPictureByBatch(PictureUploadByBatchRequest pictureUploadByBatchRequest, HttpServletRequest request) throws Exception;

    /**
     * 图片下载
     * @param pictureDownloadRequest 图片下载请求
     * @param request 请求
     */
    void downloadPicture(PictureDownloadRequest pictureDownloadRequest, HttpServletRequest request);

//    /**
//     * 图片权限检查
//     * @param picture 图片
//     * @param request 请求
//     */
//    public void checkPictureAuth(Picture picture, HttpServletRequest request);

    /**
     * 图片批量修改
     * @param pictureEditByBatchRequest 图片批量修改请求
     * @param request 批量修改的请求
     */
    @Transactional(rollbackFor = Exception.class)
    void editPictureByBatch(PictureEditByBatchRequest pictureEditByBatchRequest, HttpServletRequest request);

    /**
     * 创建AI文生图任务
     * @param textToImageRequest 文生图请求
     */
    String createTextToImageTask(TextToImageRequest textToImageRequest);

    /**
     * 创建AI编辑图片任务
     * @param pictureEditRequest 图片编辑请求
     */
    String createPictureEditTask(AIImageEditRequest pictureEditRequest);

    /**
     * 跟换用户头像
     */
    void changeUserAvatar(MultipartFile file, HttpServletRequest request) throws Exception;
}
